<template>
  <div
    :className="`${isNormalShow ? 'isNormalShow' : ''} `"
    v-html="innerHtmlStr"
  />
</template>

<script setup lang="ts">
import {
  reactive,
  ref,
  onMounted,
  computed,
  watch,
  getCurrentInstance,
} from "vue";

// 定义组件的 props
const props = defineProps({
  configXml: Object,
  footerConfig: Object,
});

let isNormalShow = ref(true);
let innerHtmlStr = ref("");

onMounted(() => {
  //console.log('3.-组件挂载到页面之后执行-------onMounted')

  //   let {config: configXml, footerConfig} = props.config;

  // footerConfig = footerConfig || {};


  let vitalFooter = props.configXml.getElementsByTagName("vitalfooter")[0];
  if (!vitalFooter) {
    return;
  }

  let innerHtml = vitalFooter.innerHTML;
  isNormalShow.value = vitalFooter.getAttribute("show") === "true";
  // let isPrintShow = vitalFooter.getAttribute('print-show') === 'true';

  innerHtml = innerHtml.replace(/&amp;/g, "").replace(/amp;/g, "");
  innerHtml = innerHtml.replace(/&lt;/g, "<").replace(/lt;/g, "<");
  innerHtml = innerHtml.replace(/&gt;/g, ">").replace(/gt;/g, ">");
  innerHtml = innerHtml.replace(/\n/g, "").replace(/↵/g, "").replace(/&/g, "");

  innerHtml = innerHtml.replace(/\{(.*?)\}/g, (param) => {
    param = param.replace("{config.", "").replace("}", "");
    return props.footerConfig[param] || "";
  });

  innerHtmlStr.value = innerHtml;

});
</script>

<style lang="scss" scoped></style>
